//
//  SoftShadowsScene.h
//  Ray Tracer
//
//  Created by Kaila, Ashish on 4/2/13.
//  Copyright (c) 2013 Kaila, Ashish. All rights reserved.
//

#ifndef Ray_Tracer_SoftShadowsScene_h
#define Ray_Tracer_SoftShadowsScene_h

void renderSoftShadowScene(Raytracer& raytracer,
                           int width,
                           int height,
                           bool enableSpecular)
{
    // Camera parameters.
	Point3D eye(0, 0, 1);
	Vector3D view(0, 0, -1);
	Vector3D up(0, 1, 0);
	double fov = 80;
    
	// Defines a material for shading.
	SolidMaterial ball(Colour(0.5, 0.5, 0.5),
                       Colour(0.5, 0.5, 0.5),
                       Colour(0.5, 0.5, 0.5),
                       10,
                       0.5,
                       0.005,
                       0);
    
	SolidMaterial jade(Colour(0, 0, 0),
                       Colour(0.54, 0.89, 0.63),
                       Colour(0.316228, 0.316228, 0.316228),
                       12.8,
                       0.5,
                       0.001,
                       0);
    
	// Defines a point light source.
    double const area = 6;
    
    bool soft = true;
    
    if (soft)
    {
	raytracer.addLightSource( new FiniteLight(Point3D(5, 3, -3),
                                              Vector3D(area, 0, 0),
                                              Vector3D(0, area, 0),
                                              10,
                                              Colour(0.9, 0.9, 0.9) ),
                             enableSpecular);
    }
    else
    {raytracer.addLightSource( new PointLight(Point3D(5, 3, -3),
                                             Colour(0.9, 0.9, 0.9) ),
                             enableSpecular);
    }
    
	// Add a unit square into the scene with material mat.
	SceneDagNode* smallplane = raytracer.addObject(new UnitSquare(&ball));
	SceneDagNode* plane = raytracer.addObject(new UnitSquare(&jade));
	
	// Apply some transformations to the unit square.
	double factor1[3] = { 2.0, 2.0, 2.0 };
	double factor2[3] = { 6.0, 6.0, 6.0 };
    
    SceneObject* smallPlaneObj = smallplane->obj;
	smallPlaneObj->translate(Vector3D(0, .5, -2));
	smallPlaneObj->rotate('x', -75);
    smallPlaneObj->scale(Point3D(), factor1);
    
    SceneObject* planeObj = plane->obj;
	planeObj->translate(Vector3D(0, 0, -3));
	planeObj->rotate('x', -75);
	planeObj->scale(Point3D(0, 0, 0), factor2);
    
	// Render the scene, feel free to make the image smaller for
	// testing purposes.
	raytracer.render(width, height, eye, view, up, fov, "softshadow.bmp");
}


#endif
